import {
  AccountParams,
  DeptListItem,
  RoleParams,
  RolePageParams,
  DeptListGetResultModel,
  AccountListGetResultModel,
  RolePageListGetResultModel,
  RoleListGetResultModel,
  ICustomDocument,
  ICustomDocumentSingle,
  ICustomDocumentBasic,
  ICustomPartSingle,
  ICustomPartClass,
  ICustomPartDocument,
  ICustomPartDocumentType,
} from './model/systemModel';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  AccountList = '/system/getAccountList',
  IsAccountExist = '/system/accountExist',
  DeptList = '/system/getDeptList',
  setRoleStatus = '/system/setRoleStatus',
  RolePageList = '/system/getRoleListByPage',
  GetAllRoleList = '/system/getAllRoleList',
  Getallpersondto = '/services/app/Persons/Getallpersondto',
  GetAllFileType = '/services/app/TiPDMFileType/GetAllTiPDMFileType',
  GetAllFileTypeIdList = '/services/app/TiPDMFileType/GetAllTiPDMFileTypeIdList',
  GetFileTypeSetting = '/services/app/TiPDMFileType/GetAllFileWeb',
  CreateFileType = '/services/app/TiPDMFileType/AddFileType',
  GetFileTypeById = '/services/app/TiPDMFileType/GetOneTiPDMFileType',
  UpdateFileType = '/services/app/TiPDMFileType/UpdateFileType',
  GetAllDocFileType = '/services/app/Pdmdoctype/GetNoBdDocType',
  GetAddFileTypeTable = '/services/app/Pdmdoctype/AddDocType',
}

export const getAccountList = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params });

export const getDeptList = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params });

export const getRoleListByPage = (params?: RolePageParams) =>
  defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });

export const getAllRoleList = (params?: RoleParams) =>
  defHttp.get<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });

export const setRoleStatus = (id: number, status: string) =>
  defHttp.post({ url: Api.setRoleStatus, params: { id, status } });

export const isAccountExist = (account: string) =>
  defHttp.post({ url: Api.IsAccountExist, params: { account } }, { errorMessageMode: 'none' });

// 用户列表接口
export const Getallpersondto = () => defHttp.get({ url: Api.Getallpersondto });

// 添加用户数据
export const AddUserData = (params: any) =>
  defHttp.post({ url: `/services/app/Persons/AddPerson`, params });

// 获取用户数据
export const GetUserData = (SelectUserId: string) =>
  defHttp.get({ url: `/services/app/Persons/GetPersonData?SelectUserId=${SelectUserId}` });

// 修改用户数据
export const UpdateUserData = (params: any) =>
  defHttp.post({ url: `/services/app/Persons/UpdatePerson`, params });

// 删除用户数据
export const DeleteUserData = (DeleteUsserId: string) =>
  defHttp.delete({ url: `/services/app/Persons/DeletePerson?DeleteUsserId=${DeleteUsserId}` });

// 获取对应用户的组织和角色数据
export const GetUserOrgRoleData = (SelectUserId: string) =>
  defHttp.get({
    url: `/services/app/Persons/GetPersonOrgAndFunction?SelectUserId=${SelectUserId}`,
  });

// 获取部门树形结构列表
export const GetAllOrgTreeData = () =>
  defHttp.get({
    url: `/services/app/Orgs/GetAllOrgTreeData`,
  });

// 新建用户个人印章上传
export const UpLoadPersonBMP = (params: any) =>
  defHttp.post({
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    url: `/services/app/Task/UpLoadPersonBMP`,
    params,
  });

// 浏览对应用户签章文件
export const GetPersonUploadBMP = (SelectUserid: string) =>
  defHttp.get({
    url: `/services/app/Task/GetPersonBMPUrl?SelectUserid=${SelectUserid}`,
  });

// 删除用户对应个人印章文件
export const DeletePersonUploadBMP = (FileName: string, IsUpLoad: string, SelectUserid: string) =>
  defHttp.delete({
    url: `/services/app/Task/DeletePersonUploadBMP?FileName=${FileName}&IsUpLoad=${IsUpLoad}&SelectUserid=${SelectUserid}`,
  });

// 冻结用户数据
export const BlockedPerson = (BlockedUsserId: string) =>
  defHttp.post({
    url: `/services/app/Persons/BlockedPerson?BlockedUsserId=${BlockedUsserId}`,
  });

// 获取组织树形结构列表
export const GetAllOrgTreeDataHaveCompany = (ParentId: string) =>
  defHttp.get({
    url: `/services/app/Orgs/GetAllOrgTreeDataHaveCompany?ParentId=${ParentId}`,
  });

// 获取对应组织的用户列表
export const GetOrgPersons = (OrgId: string) =>
  defHttp.get({
    url: `/services/app/Orgs/GetOrgPersons?OrgId=${OrgId}`,
  });

// 获取对应组织的对应用户和所有用户数据
export const GetOrgsChangePerson = (OrgId: string) =>
  defHttp.get({
    url: `/services/app/Orgs/GetOrgsChangePerson?OrgId=${OrgId}`,
  });

// 修改对应组织的对应用户数据
export const ChangeOrgsPerson = (OrgId: string, params: any) =>
  defHttp.post({
    url: `/services/app/Orgs/ChangeOrgsPerson?OrgId=${OrgId}`,
    params,
  });

// 新建组织
export const AddOrgs = (params: any) =>
  defHttp.post({
    url: `/services/app/Orgs/AddOrgs`,
    params,
  });

// 获取组织数据
export const GetOrgsData = (OrgId: string) =>
  defHttp.get({
    url: `/services/app/Orgs/GetOrgsAndHierarchy?OrgId=${OrgId}`,
  });

// 修改组织
export const UpdateOrgs = (params: any) =>
  defHttp.put({
    url: `/services/app/Orgs/UpdateOrgs`,
    params,
  });

// 删除组织
export const DeleteOrgs = (OrgId: string) =>
  defHttp.delete({
    url: `/services/app/Orgs/DeleteOrgs?OrgId=${OrgId}`,
  });

// 获取所有角色数据
export const GetAllFunctionRole = () =>
  defHttp.get({
    url: `/services/app/FunctionRole/GetAllFunctionRole`,
  });

// 新建角色
export const AddFunctionRole = (params: any) =>
  defHttp.post({
    url: `/services/app/FunctionRole/AddFunctionRole`,
    params,
  });

// 获取角色
export const GetFunctionRole = (FunctionRoleId: string) =>
  defHttp.get({
    url: `/services/app/FunctionRole/GetFunctionRole?FunctionRoleId=${FunctionRoleId}`,
  });

// 修改角色
export const UpdateFunctionRole = (params: any) =>
  defHttp.put({
    url: `/services/app/FunctionRole/UpdateFunctionRole`,
    params,
  });

// 删除角色
export const DeleteFunRole = (FunId: string) =>
  defHttp.delete({
    url: `/services/app/FunctionRole/DeleteFunRole?FunId=${FunId}`,
  });

// 获取对应角色系统菜单权限
export const GetFunctionRolePdmFunction = (FunctionRoleId: string) =>
  defHttp.get({
    url: `/services/app/FunctionRole/GetFunctionRolePdmFunction?FunctionRoleId=${FunctionRoleId}`,
  });

// 修改对应角色系统菜单权限
export const UpdateFunctionRolePdmFunction = (params: any) =>
  defHttp.put({
    url: `/services/app/FunctionRole/UpdateFunctionRolePdmFunction`,
    params,
  });

// 获取所有的文件类型数据
export const getAllFileType = () => defHttp.get({ url: Api.GetAllFileType });

// 获取所有的文件类型id列表
export const getAllFileTypeIdList = () => defHttp.get({ url: Api.GetAllFileTypeIdList });

// 获取文件类型设置通用浏览器下拉列表
export const getFileTypeSetting = () => defHttp.get({ url: Api.GetFileTypeSetting });

// 新建文件类型
export const createFileType = (formData: any) =>
  defHttp.request({
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'POST',
    url: Api.CreateFileType,
    params: formData,
  });

// 单条查询图文档类型
export const getFileTypeById = (FileId: string) =>
  defHttp.get({ url: Api.GetFileTypeById, params: { FileId } });

// 修改文件类型数据
export const updateFileType = (formData: any) =>
  defHttp.request({
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'POST',
    url: Api.UpdateFileType,
    params: formData,
  });

// 删除指定文件类型数据
export const deleteFileType = (FileTypeId: string) =>
  defHttp.delete({ url: `/services/app/TiPDMFileType/DeleteFileType?FileTypeId=${FileTypeId}` });

// 查询所有图档类型表数据
export const getAllFileTypeTable = () => defHttp.get({ url: Api.GetAllDocFileType });

// 添加自定义图文档数据
export const addFileTypeTable = (params: ICustomDocument) =>
  defHttp.post({ url: Api.GetAddFileTypeTable, params });

// 获取对应图文档数据
export const getFileTypeTable = (DocType: string) =>
  defHttp.get({ url: `/services/app/Pdmdoctype/GetDocType?DocType=${DocType}` });

// 获取编码关联列表数据
export const getCodeList = () => defHttp.get({ url: `/services/app/Pdmdoctype/GetTiPDMCounter` });

// 添加单个图文档类属性
export const addDocType = (params: ICustomDocumentSingle) =>
  defHttp.post({ url: `/services/app/Pdmdoctype/AddDocTypeItem`, params });

// 删除单个图文档类属性
export const deleteDocType = (DocTypeId: string, ItemProp: string, ItemIndex: number) =>
  defHttp.delete({
    url: `/services/app/Pdmdoctype/DeleteDocTypeItem?DocTypeId=${DocTypeId}&ItemProp=${ItemProp}&ItemIndex=${ItemIndex}`,
  });

// 修改单个图文档类属性
export const updateDocType = (params: ICustomDocumentSingle) =>
  defHttp.put({ url: `/services/app/Pdmdoctype/UpdateDocTypeItem`, params });

// 获取未/已绑定图档类型列表
export const getNoBdDocType = (DocTypeId: string) =>
  defHttp.get({ url: `/services/app/Pdmdoctype/GetBingFileTypeList?DocTypeId=${DocTypeId}` });

// 修改已绑定图档类型列表
export const updateBingDocType = (DocTypeId: string, params: any) =>
  defHttp.put({
    url: `/services/app/Pdmdoctype/UpdateBingFileTypeList?DocTypeId=${DocTypeId}`,
    params,
  });

//获取对应图文档提取对应数据列表
export const getDocTypeDataList = (DocTypeId: string) =>
  defHttp.get({ url: `/services/app/Pdmdoctype/GetDocTypeDictionary?DocTypeId=${DocTypeId}` });

// 获取对应图文档提取对应数据列表中的系统名称下拉列表，返回3个列表
export const getDocTypeDataListSystem = (DocTypeId: string) =>
  defHttp.get({
    url: `/services/app/Pdmdoctype/GetDocTypeDictionarySysNameList?DocTypeId=${DocTypeId}`,
  });

// 修改图文档提取对应模板（未完成，需要后续调用pdm方法)
export const updateDocTypeDataList = (DocTypeId: string, params: any) =>
  defHttp.put({
    url: `/services/app/Pdmdoctype/UpdateDocTypeDictionary?DocTypeId=${DocTypeId}`,
    params,
  });

// 删除图文档提取对应模板和对应数据
export const deleteDocTypeDataList = (DocTypeId: string) =>
  defHttp.delete({
    url: `/services/app/Pdmdoctype/DeleteDocTypeDictionary?DocTypeId=${DocTypeId}`,
  });

// 下载图文档提取对应模板mod文件
export const downloadDocTypeDataList = (DocTypeId: string) =>
  defHttp.export(
    {
      url: `/services/app/Task/DownLoadDocTypeDictionaryMod?DocTypeId=${DocTypeId}`,
    },
    '模板.mod',
  );

// 修改自定义图文档基本属性
export const updateDocTypeBase = (params: ICustomDocumentBasic) =>
  defHttp.put({
    url: `/services/app/Pdmdoctype/UpdateDocTypeMain`,
    params,
  });

// 添加图文档对应模板数据
export const addDocTypeDataList = (DocTypeId: string, params: any) =>
  defHttp.post({
    url: `/services/app/Task/AddDocTypeTemplate?DocTypeId=${DocTypeId}`,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    params,
  });

// 下载图文档模板文件
export const downloadDocTypeTemplate = (DocTypeId: string) =>
  defHttp.post({
    url: `/services/app/Task/DownLoadDocType?DocTypeId=${DocTypeId}`,
  });

// 删除指定图文档数据
export const deleteDocTypeData = (DocTypeId: string) =>
  defHttp.delete({
    url: `/services/app/Pdmdoctype/DeleteDocType?DocTypeId=${DocTypeId}`,
  });

// 获取零件分类列表
export const getAllPartClass = () =>
  defHttp.get({ url: `/services/app/PartRevision/GetPartTypeList` });

// 获取零件特征项设置和对应下拉列表
export const getPartFeature = () =>
  defHttp.get({ url: `/services/app/PartRevision/GetPartFeature` });

// 修改总零件特征项设置
export const updatePartFeature = (FirstFeature: string, SecondFeature: string) =>
  defHttp.put({
    url: `/services/app/PartRevision/UpdatePartFeature?FirstFeature=${FirstFeature}&SecondFeature=${SecondFeature}`,
  });

// 获取零件类属性列表
export const getPartFeatureList = () =>
  defHttp.get({ url: `/services/app/PartRevision/GetPartItemList` });

// 添加单个零件类属性
export const addPartFeatureList = (params: ICustomPartSingle) =>
  defHttp.post({ url: `/services/app/PartRevision/AddPartItem`, params });

// 删除单个零件类属性
export const deletePartFeatureList = (PartTypeId: string, ItemProp: string, ItemIndex: number) =>
  defHttp.delete({
    url: `/services/app/PartRevision/DeletePartItem?PartTypeId=${PartTypeId}&ItemProp=${ItemProp}&ItemIndex=${ItemIndex}`,
  });

// 修改单个零件类属性
export const updatePartFeatureList = (params: ICustomPartSingle) =>
  defHttp.put({ url: `/services/app/PartRevision/UpdateDocTypeItem`, params });

// 新建零件分类
export const createPartClass = (params: ICustomPartClass) =>
  defHttp.post({ url: `/services/app/PartRevision/AddPartType`, params });

// 修改零件分类
export const updatePartClass = (params: ICustomPartClass) =>
  defHttp.put({ url: `/services/app/PartRevision/UpdatePartType`, params });

// 删除零件分类
export const deletePartClass = (PartId: string) =>
  defHttp.delete({
    url: `/services/app/PartRevision/DeletePartType?PartId=${PartId}`,
  });

// 获取零件分类属性列表
export const getPartClassPropertyList = (PartId: string) =>
  defHttp.get({ url: `/services/app/PartRevision/GetPartTypePropList?PartId=${PartId}` });

// 修改零件分类属性列表
export const updatePartClassPropertyList = (PartId: string, params: any) =>
  defHttp.put({
    url: `/services/app/PartRevision/UpdatePartTypePropList?PartId=${PartId}`,
    params,
  });

// 获取零件图档绑定相关列表
export const getPartDocTypeList = (PartId: string) =>
  defHttp.get({ url: `/services/app/PartRevision/GetPartTypePropbill?PartId=${PartId}` });

// 修改零件绑定图档相关
export const updatePartDocTypeList = (PartId: string, params: any) =>
  defHttp.put({
    url: `/services/app/PartRevision/UpdatePartBill?PartId=${PartId}`,
    params,
  });

// 零件和图档关联表和入库设置
export const getPartDocTypeListAndInStore = () =>
  defHttp.get({ url: `/services/app/PartRevision/GetPartDocListAndOption` });

// 修改入库设置
export const updatePartDocTypeListAndInStore = (Optionstr: string) =>
  defHttp.put({
    url: `/services/app/PartRevision/UpdateRkOption?Optionstr=${Optionstr}`,
  });

// 添加零件与图文档关联关系
export const addPartDocTypeList = (params: ICustomPartDocument) =>
  defHttp.post({ url: `/services/app/PartRevision/AddPartAndDocRelationship`, params });

// 删除零件与图文档关联关系
export const deletePartDocTypeList = (params: any) =>
  defHttp.post({ url: `/services/app/PartRevision/DelerPartAndDocRelationship`, params });

// 修改零件与图文档关联关系
export const UpdatePartAndDocRelationship = (params: ICustomPartDocument) =>
  defHttp.put({ url: `/services/app/PartRevision/UpdatePartAndDocRelationship`, params });

// 获取零件属性和图档属性下拉列表
export const GetPartAndDocTypeXL = () =>
  defHttp.get({ url: `/services/app/PartRevision/GetPartAndDocTypeXL` });

// 获取编码类型列表数据
export const getCodeTypeList = () =>
  defHttp.get({ url: `/services/app/PartRevision/GetTiPDMCounter` });

// 删除对应编码类型
export const deleteCodeTypeList = (CounterID: string, Remark: string, MdList: any) =>
  defHttp.delete({
    url: `/services/app/PartRevision/DeleteTiPDMCounter?CounterID=${CounterID}&Remark=${Remark}&MdList=${MdList}`,
  });

// 添加对应编码类型
export const addCodeTypeList = (params: ICustomPartDocumentType) =>
  defHttp.post({ url: `/services/app/PartRevision/AddTiPDMCounter`, params });

// 修改对应编码类型
export const updateCodeTypeList = (params: ICustomPartDocumentType) =>
  defHttp.put({ url: `/services/app/PartRevision/UpdateTiPDMCounter`, params });

// 浏览对应图文档类型模板文件
export const GetDocFileTemplateUrl = (DocFile: string) =>
  defHttp.get({
    url: `/services/app/Task/GetDocFileTemplateUrl?DocFile=${DocFile}`,
  });

/**
 * 模块名:添加图文档提取对应模板mod文件进服务器指定文件夹，并加载提取项对应内容
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/04/17 11:23:06
 */
export const AddDocTypeTemplate = (DocTypeId: string, formData: any) =>
  defHttp.post({
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    url: `/services/app/Pdmdoctype/AddDocTypeTemplate?DocTypeId=${DocTypeId}`,
    params: formData,
  });

// 查询所有表单类型表数据
export const GetAllBdDocType = () =>
  defHttp.get({ url: `/services/app/Pdmdoctype/GetAllBdDocType` });

// 查询所有表单类型表数据左侧树形结构参数
export const GetAllBdTree = () =>
  defHttp.get({
    url: `/services/app/Pdmdoctype/GetAllBdTree`,
  });

// 查询所有表单属性页定义列表
export const GetBdPropertyPage = () =>
  defHttp.get({
    url: `/services/app/Pdmdoctype/GetBdPropertyPage`,
  });

// 查询对应表单属性页定义的绑定表单属性组列表
export const GetBdPropertyPageAndTeam = (PageId: string) =>
  defHttp.get({
    url: `/services/app/Pdmdoctype/GetBdPropertyPageAndTeam?PageId=${PageId}`,
  });

// 修改所有表单属性页定义列表和对应的绑定表单属性组列表
export const ChangeBdPropertyPageAndTeam = (params: any) =>
  defHttp.post({
    url: `/services/app/Pdmdoctype/ChangeBdPropertyPageAndTeam`,
    data: params,
  });

// 查询所有表单属性组定义列表
export const GetBdAllPropertyTeam = () =>
  defHttp.get({
    url: `/services/app/Pdmdoctype/GetBdAllPropertyTeam`,
  });

// 修改所有表单属性组列表
export const ChangeBdPropertyTeam = (params: any) =>
  defHttp.post({
    url: `/services/app/Pdmdoctype/ChangeBdPropertyTeam`,
    data: params,
  });

// 获取所有表单属性页定义和绑定表单属性组数据
export const GetAllBdPropertyPageAndTeam = () =>
  defHttp.get({
    url: `/services/app/Pdmdoctype/GetAllBdPropertyPageAndTeam`,
  });

// 获取表单对应已有表格分组列表
export const GetBdGroupNameList = (BdId: string) =>
  defHttp.get({
    url: `/services/app/Pdmdoctype/GetBdGroupNameList?BdId=${BdId}`,
  });
